package com.goods.controller.busniess;

import com.github.pagehelper.PageInfo;
import com.goods.business.service.InStockService;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.InStockDetailVO;
import com.goods.common.vo.business.InStockVO;
import com.goods.common.vo.business.ProductVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @description：
 * @version:
 * @author：ruixinag
 * @create：Created in 2021/11/9 4:00
 */
@Api(tags = "业务模块-入库")
@RestController
@RequestMapping("/business/inStock")
public class InStockController {
    @Autowired
    private InStockService inStockService;

    //入库单（入库记录）数据分页列表展示
    @ApiOperation("入库单（入库记录）数据分页列表展示")
    @GetMapping("/findInStockList")
    public ResponseBean findInStockList(
            @RequestParam Map paramMap
    ){

        Map map=inStockService.findInStockList(paramMap);

        return ResponseBean.success(map);
    }

    //入库明细
    //detail/112?pageNum=1
    @ApiOperation("入库明细")
    @GetMapping("/detail/{inStockId}")
    public ResponseBean<InStockDetailVO> detail(
            @PathVariable Long inStockId,int pageNum
    ){

        InStockDetailVO inStockDetailVO= inStockService.detail(inStockId,pageNum);

        //查出
        //map.put("itemVOS",null);
        //map.put("total",null);
        ////供应商信息,根据id
        //map.put("supplierVO",null);
        ////入库单的状态
        //map.put("status",null);
        return ResponseBean.success(inStockDetailVO);
    }

    //回收站,/remove/112
    @ApiOperation("回收站")
    @PutMapping("/remove/{inStockId}")
    public ResponseBean remove(
            @PathVariable Long inStockId
    ){
        inStockService.remove(inStockId);
        return ResponseBean.success();
    }

    //还原,/back/112
    @ApiOperation("还原")
    @PutMapping("/back/{inStockId}")
    public ResponseBean back(
            @PathVariable Long inStockId
    ){
        inStockService.back(inStockId);
        return ResponseBean.success();
    }
    
    //新增入库单
    @ApiOperation("新增入库单")
    @PostMapping("/addIntoStock")
    public ResponseBean addIntoStock(
            @RequestBody  InStockVO inStockVO
    ){
        inStockService.addIntoStock(inStockVO);
        return ResponseBean.success();
    }

    //审核通过,增加库存
    @ApiOperation("审核通过")
    @PutMapping("/publish/{inStockId}")
    public ResponseBean publish(
            @PathVariable Long inStockId
    ){
        inStockService.publish(inStockId);
        return ResponseBean.success();
    }

    //删除入库单
    @ApiOperation("删除入库单")
    @GetMapping("/delete/{inStockId}")
    public ResponseBean delete(
            @PathVariable Long inStockId
    ){
        inStockService.delete(inStockId);
        return ResponseBean.success();
    }



}
